Post

Replies

Boosts

Views

Activity

Reply to Recipe for Building OpenSSL static library for Apple Silicon & Intel?
@MyMattes Thanks for sharing that repository. I wasn't able to get this to build though. I keep getting the following error: error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: can't open file: MacOSX10.11-x86_64.sdk/lib/libcrypto.a (No such file or directory) Do you know where I could be going wrong here?
Topic: App & System Services SubTopic: Hardware Tags:
Jan ’21
Reply to NSTextField check if first responder without notification?
You should be checking for the NSTextField's field editor, because NSTextFields don't become the window's firstResponder even when they have focus (one of the quirks of AppKit). Search about the field editor. To check if a text field is being edited try using currentEditor property instead like this: if (someTextField.currentEditor != nil) { //editing } else { //not editing... }
Topic: UI Frameworks SubTopic: AppKit Tags:
Feb ’21
Reply to Pop Up buttons in Interface Builder don't show menu in iOS 15
This API is so weird. I don't know why they didn't just copy the API from NSPopUpButton. You can wire a selector to the menu items in Interface Builder (apparently no target though...) so the items must dig through the responder chain to find something that implements the selector. If you don't wire the selector for each menu item in IB, then the menu won't show up when you tap the button. So bizarre. Not sure if I'm doing something wrong but I also have to manually change the title on the button in the action -(IBAction)popUpButtonAction:(UICommand*)sender { self.mainPopUpbutton.title = sender.title; } Doing the above fixes the button title problem... but next time the button is clicked, the wrong menu item has the checkmark. I tried changing the state in the action method, but that throws an exception: -(IBAction)popUpButtonAction:(UICommand*)sender { self.mainPopUpbutton.title = sender.title;  sender.state = UIMenuElementStateOn; // not allowed.. } Also be careful wiring an UIButton IBOutlet to the pop up button (have to do it in the document outline... if you try to wire it to the button in a storyboard scene it actually wires the UIButton IBOutlet to the UIMenu!) Implementing one of these in a UITableview is awful BTW.
Topic: UI Frameworks SubTopic: UIKit Tags:
Nov ’21
Reply to NSKeyedArchiver
Did you try using +unarchivedObjectOfClasses:fromData:error: method instead and specify all the classes that may appear in your dictionary in the classes param?  NSError *error = nil;   id rootObject =  [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class],                                                                        [NSData class],                                                                      [NSString class]]] //include whatever classes are in your dictionary                                         fromData:data                                            error:&error];
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to Memory mapped file: "Cannot allocate memory"
Just stumbled upon this in an app I'm working on. I set a symbolic breakpoint on malloc_error_break which ends up getting hit on the following line in my code:    CGImageRef cgImage = CGImageSourceCreateThumbnailAtIndex(imageSource,                                                              0,                                                              (CFDictionaryRef)options); The imageSource above is created via a CGImageSourceCreateWithURL function call. I use this to load images in a table view. All works well, but after scrolling the table view for awhile it appears I hit the address space limit. I don't use mmap directly and after I get CGImage's from above I covert them to UIImage and release it: CFRelease(imageSource); CFRelease(imageProperties);  if (cgImage != NULL)     {         UIImage *uiIMage = [[UIImage alloc]initWithCGImage:cgImage];         CGImageRelease(cgImage);         return uiIMage;     } The returned UIImages are held in a NSCache object. Is it possible that CGImageSourceCreateThumbnailAtIndex is causing me to hit the address space limit? I don't appear to have a memory leak here so I'm not sure why my address space limit would keep accumulating as I continue scrolling the table view. The image source and CGImage are released after converting to a UIImage.
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’22
Reply to Memory mapped file: "Cannot allocate memory"
Cool got it. Thanks for the reply. I'm guessing the answer tot his question is no but I'll ask anyway. Is there any API on iOS to detect when an app's address space limit is getting close to being hit? That is, to be notified preemptively before hitting the limit so I can free some, rather than waiting for a ENOMEM to occur..and then freeing up address space?
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’22
Reply to NSMutableArray does not raise NSRangeException when trying to set an element at the end of the array
The code shown for your array named a should work. You have: NSMutableArray<NSNumber*> *a = @[@(0), @(0), @(0)].mutableCopy; a[3] = @(1); // works, but why? a[4] = @(1); // also works So you have three NSNumbers in an array at index 0, 1, 2. Then you add another number at index 3, which would be the same thing as doing this: [a addObject:@(1)]; I could be wrong but I believe the line in the documentation below is wrong: If index is beyond the end of the array (that is, if index is greater than or equal to the value returned by count), an NSRangeException is raised. I think it should say: If index is beyond the end of the array (that is, if index is greater than the value returned by count), an NSRangeException is raised. The documentation also says: Replaces the object at the index with the new object, possibly adding the object. You probably should file a bug. Either the documentation or the code is wrong but I believe it is the documentation.
Topic: App & System Services SubTopic: General Tags:
Mar ’22
Reply to StoreKit Testing Not Working for Existing macOS App. Receipt Validation Fails and gives me App Sandbox Receipt
This apparently hasn't changed. Xcode 13.2.1 receipt validation fails when I try to verify against the generated public certificate from the StoreKit configuration file. Receipt validation passes when I validate against the Apple root certificate...but then I'm in the sandbox environment and lose the benefits of StoreKit configuration testing.
Topic: App & System Services SubTopic: StoreKit Tags:
Apr ’22
Reply to Subscription Renewal Rate in StoreKit Testing for Xcode Not Working For Subscriptions Unless They Are Monthly Subscriptions?
Thanks a lot for the reply. This was helpful. After changing "Monthly renewal rate to every 30 seconds" and making the purchase in the simulator, my weekly renewal subscription code is working. I think it would be nice to be able to set a renewal rate relative to weekly/yearly subscriptions in a more intuitive fashion, but at least this works. The autorenewable subscription code is triggered, but for my weekly subscription, the expiration date is actually not advanced a week into the future. For example here are two expiration date values in the separate in app purchase receipts after a renewal: 2022-05-02 21:23:10 +0000 2022-05-02 21:20:47 +0000 So in my UI I have an area: "Subscription expires on 5/02/22" After each renewal, this UI refreshes. But because the way Storekit testing works the label never actually changes. It would be cool if the expiration date in the receipt refreshed from 5/02/22 to 5/09/22 and so on, which would make a more realistic test environment.
Topic: App & System Services SubTopic: StoreKit Tags:
May ’22
Reply to StoreKit Configuration File: Auto-Renewable Subscriptions Suddenly Stop Working in StoreKit Testing Environment After Awhile
Also to add when this issue happens (suddenly unsubscribed without taking any user interaction) if I go to the "Manage StoreKit Transactions" window in Xcode while my app is running a debug session and view transactions, indeed the latest transaction in the list is "Expired." If I click the "Subscription Options" button it says "Select an Option to Resubscribe." I've taken no user interaction to unsubscribe to the subscription plan I'm currently testing. StoreKit Testing seems to just randomly unsubscribe me from the subscription plan. Anyone else run into this?
Topic: App & System Services SubTopic: StoreKit Tags:
May ’22
Reply to UINavigationController's interactivePopGestureRecognizer sometimes causes the popped view controller to never be released (memory leak)
Thanks a lot for your response. That was very helpful (not sure why I didn't think of using the memory graph debugger duh)! The leak is caused by UISwipeActionsConfiguration. The view controller that is being leaked has a UITableView and implements the delegate method: -(nullable UISwipeActionsConfiguration*)tableView:(UITableView*)tableView leadingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath*)indexPath So the leak occurs when I start the navigation controller's interactive pop gesture and the table view simultaneously recognizes the gesture and calls the -tableView:leadingSwipeActionsConfigurationForRowAtIndexPath: method and I return a UISwipeActionsConfiguration just before the view controller is popped off the stack via the interactive pop gesture recognizer... The private UISwipeActionController is still holding on to the UISwipeActionsConfiguration, which is holding on to my view controller even after it has been dismissed from the UI, thus causing the leak. Ouch!
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’22
Reply to UINavigationController's interactivePopGestureRecognizer sometimes causes the popped view controller to never be released (memory leak)
Just to add (for anyone else out there interested), reproducing the issue is a bit tricky. You have to invoke the interactive pop gesture a certain way to get the table view delegate method to be called, and then just pop it off in one motion. For me I set a log in -(nullable UISwipeActionsConfiguration*)tableView:(UITableView*)tableView leadingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath*)indexPath { NSLog(@"-leadingSwipeActionsConfigurationForRowAtIndexPath called"); UISwipeActionsConfiguration *theConfig; //make the object and return it.. return theConfig; } I also set a log in dealloc to verify whether or not the view controller is released. So I have to play with it a few times, push and pop the view controller. But when I see the log in -leadingSwipeActionsConfigurationForRowAtIndexPath: and I still have my finger down (and the interactive pop gesture is still recognizing my touch) and I pop off the view controller, my log in dealloc does not show up and the view controller leaks. I carefully went through each UIContextualAction I pass to the UISwipeActionsConfiguration and do a __weak and __strong dance like this: __weak MyViewController *weakSelf = self;    UIContextualAction *myAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal                                                                                          title:actionTitle                                                                                        handler:^(UIContextualAction *action,                                                                                                  UIView *sourceView,                                                                                                  void (^completionHandler)(BOOL))  { __strong MyViewController *strongSelf = weakSelf; //do whatever to respond to the action using strongSelf. }]; I believe this has now allowed my view controller to be released when I reproduce the issue, since the UIContextualActions don't retain the view controller in their action handlers. I think the UISwipeActionsConfiguration is still leaking though....with no obvious way for me to clear it when the view controller gets popped off the navigation stack (UISwipeActionController is private API). But at least the leak is not as bad. Instruments leak tool never picked up this leak I only found it by unexpectedly hitting breakpoints on a view controller that wasn't supposed to be in memory.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’22